﻿IF EXISTS (SELECT * from sys.procedures p left join sys.schemas s on p.schema_id = s.schema_id where p.name='contact_update' and s.name='Crm')
DROP PROCEDURE [Crm].contact_update
GO
CREATE PROCEDURE [Crm].contact_update 
@PK uniqueidentifier, 
@AccountID uniqueidentifier, 
@Title nvarchar(100), 
@Name nvarchar(100), 
@GivenName nvarchar(100), 
@Function nvarchar(100), 
@Phone1 nvarchar(15), 
@Phone2 nvarchar(15), 
@Fax nvarchar(15), 
@Mail nvarchar(100), 
@Address nvarchar(500), 
@ZipCode nvarchar(5), 
@City nvarchar(100), 
@Country nvarchar(100), 
@UseAccountInfos bit
AS
BEGIN
UPDATE [Crm].[Contacts] 
SET	[id_account] = @AccountID ,
	[title] = @Title ,
	[name] = @Name ,
	[given_name] = @GivenName ,
	[function] = @Function ,
	[phone1] = @Phone1 ,
	[phone2] = @Phone2 ,
	[fax] = @Fax ,
	[mail] = @Mail ,
	[address] = @Address ,
	[zip_code] = @ZipCode ,
	[city] = @City ,
	[country] = @Country ,
	[use_account_infos] = @UseAccountInfos 
WHERE
	[id_contact] = @PK 
END